# uncompyle6 version 3.2.3
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.6.8 |Anaconda custom (64-bit)| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: helpers\__init__.py
__author__ = "sanyi"
import pkgutil, inspect
from api.handlers import ResourceHandler


def extract_handler_classes(base_module):
    result = {}
    for importer, module_name, is_package in pkgutil.iter_modules(base_module.__path__):
        if not is_package:
            module_package_path = base_module.__package__.split(".") + [module_name]
            imp = __import__((".").join(module_package_path))
            m = imp
            for key in module_package_path[1:]:
                m = getattr(m, key)

            for key in m.__dict__:
                handler_class = getattr(m, key)
                if inspect.isclass(handler_class):
                    result[handler_class.__name__] = (
                        issubclass(handler_class, ResourceHandler)
                        and handler_class != ResourceHandler
                        and handler_class
                    )

    return result
